package com.exd.flink.sink.business;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.apache.flink.connector.jdbc.JdbcStatementBuilder;

import com.exd.flink.common.StringTool;
import com.exd.flink.domain.VDataBean;

public class VdataFullIndexDataSink implements JdbcStatementBuilder<VDataBean> {

	private static final long serialVersionUID = 1L;

	@Override
	public void accept(PreparedStatement preparedStatement, VDataBean dataBean) throws SQLException {
		preparedStatement.setString(1, dataBean.getVin());
		preparedStatement.setString(2, dataBean.getServiceId());
		preparedStatement.setString(3, dataBean.getServiceName());
		preparedStatement.setString(4, String.valueOf(dataBean.getDeployId()));
		preparedStatement.setObject(5, StringTool.LongToDateString(dataBean.getCollectTime()));
		preparedStatement.setInt(6, dataBean.getPacketSequence());
		preparedStatement.setObject(7, StringTool.LongToDateString(dataBean.getTriggerStartTime()));
		preparedStatement.setObject(8, StringTool.LongToDateString(dataBean.getTriggerEndTime()));
		preparedStatement.setObject(9, StringTool.LongToDateString(dataBean.getSamplingTime()));
		preparedStatement.setObject(10, StringTool.getNowDateString());
	}

}
